package com.dwyinyuan.infrastructure.config;

import org.springframework.context.annotation.*;
import springfox.documentation.builders.*;
import springfox.documentation.service.*;
import springfox.documentation.spi.*;
import springfox.documentation.spring.web.plugins.*;
import springfox.documentation.swagger2.annotations.*;


/**
 * 微信公众号：笛舞音缘
 * <p>
 * Swagger2配置类
 *
 * 访问地址 localhost:8080/swagger-ui.html
 * <p>
 * Created by andy  on 2020-12-16.
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    /**
     * Swagger2信息
     *
     * @return
     */
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                // API 基本信息
                .apiInfo(apiInfo())

                // 设置允许暴露的接口
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dwyinyuan.interfaces.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * API基本信息
     *
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("fs-coding项目")
                .description("风骚编程系列整合实战项目。")
                .contact(new Contact("笛舞音缘", "", ""))
                .version("1.0.0")
                .build();
    }

}
